package com.wxhandle.cleandemo;

import com.wxhandle.cleandemo.api.config.AuditorAwareImpl;
import com.wxhandle.cleandemo.api.security.BeanUtil;

import org.modelmapper.ModelMapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@EnableCaching
public class CleanApiApplication {
	@Bean
	public AuditorAware<String> auditorAware() {
	   return new AuditorAwareImpl();
	}
	@Bean
	public ModelMapper modelMapper() {
		return new ModelMapper();
	}

	public static void main(String[] args) {
        //run方法的返回值ConfigurableApplicationContext继承了ApplicationContext上下文接口
		BeanUtil.applicationContext = SpringApplication.run(CleanApiApplication.class, args);
	}

}
